package com.csaba.connector.bha.model;

import com.csaba.connector.bha.SimpleNodeHelper;
import com.csaba.connector.model.Amount;
import com.csaba.connector.model.Customer;
import com.ind.simplenode.SimpleNode;

public class BHALoanAccount extends BHAAccount
{
	public BHALoanAccount()
	{
		super();
	}

	public BHALoanAccount( Customer customer, SimpleNode properties )
	{
		super(customer, properties);

		setNumber(SimpleNodeHelper.getAndRemove(properties, "branch") + " " + properties.getStringPath("type.code")
				+ " " + SimpleNodeHelper.getAndRemove(properties, "reference"));

		setIBAN("");
		setName(""); //no friendly name is supported by the bank
		setType(properties.getStringPath("type.code")); //XXX there should be some better value for this

		String fund = SimpleNodeHelper.getAndRemove(properties, "fund");
		setAvailableBalance(new Amount(Double.valueOf(fund), getCurrency()));
		String currentAmount = SimpleNodeHelper.getAndRemove(properties, "currentAmount");
		setBookedBalance(new Amount(Double.valueOf(currentAmount), getCurrency()));

		SimpleNodeHelper.setAmountProperty(this, properties, "openAmount", getCurrency());

		SimpleNodeHelper.loadProperties(this, properties);
	}
	/*
	<loans>
		<branch>DEMO</branch>
		<type>
	*		<code>HS5</code>
		</type>
	*		<reference>100011223</reference>
	*	<currency>HUF</currency>
	*		<currentAmount>685825.00</currentAmount>
	*	<fund>22022.00</fund>
		<interest>0</interest>
		<nextDate>__CURRENTDATE</nextDate>
		<currentInterest>25</currentInterest>
		
		<openAmount>740000.00</openAmount>
		<startDate>__CURRENTDATE-12M</startDate>
		<endDate>__CURRENTDATE+342D</endDate>
	</loans>*/

}
